/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.liquidByte.trafficMustang.server.webService;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.*;
import org.liquidByte.trafficMustang.server.services.LoginService;
import org.liquidByte.trafficMustang.server.webService.base.WebService;
import org.liquidByte.trafficMustang.server.webService.dto.LoginDTO;

/**
 * REST Web Service
 *
 * @author Alexandre
 */
@Stateless
@Path("login")
public class LoginWebService extends WebService {
    
    @EJB
    private LoginService service;
    
    @POST
    @Produces("application/json")
    @Consumes("application/json")
    @Path("auth")
    public String auth(String data) {
        try {
            LoginDTO login = this.toObject(data, LoginDTO.class);
            this.service.autenticar(login.getDocumentoIdent(), login.getSenha());
            return this.success();
        } catch (Exception e) {
            return this.error(e);
        }
    }
}
